<template>
  <div class="digital-man-container">
    <div class="content-wrapper">
      <div class="upload-section">
        <div class="section-title">
          <h2>上传图片</h2>
          <p class="description">上传您的照片，生成个性化3D数字人形象</p>
        </div>

        <div class="upload-area">
          <div class="image-preview">
            <img
              v-if="previewImage"
              :src="previewImage"
              alt="上传图片"
              class="preview-image"
            />
            <div v-else class="upload-placeholder">
              <el-icon :size="30"><Picture /></el-icon>
              <p>请选择一张照片</p>
            </div>
          </div>
          <div class="upload-actions">
            <el-upload
              class="upload-component"
              action="#"
              :auto-upload="false"
              :show-file-list="false"
              :on-change="handleImageChange"
            >
              <el-button type="primary" class="upload-btn">
                <el-icon><Upload /></el-icon>
                <span>{{ previewImage ? "重新上传图片" : "上传图片" }}</span>
              </el-button>
            </el-upload>
            <p class="upload-tip">支持 JPG、PNG 格式，大小不超过 5MB</p>
          </div>
        </div>

        <!-- 添加描述输入框 -->
        <div class="description-area">
          <div class="textarea-header">
            <span class="required-mark">*</span>
            <h3>形象描述</h3>
          </div>
          <el-input
            v-model="imageDescription"
            type="textarea"
            :rows="4"
            placeholder="请描述您想要生成的数字人形象特点，例如：服装风格、场景背景、肢体动作等"
            resize="none"
            maxlength="200"
            show-word-limit
          />
        </div>

        <div class="generation-actions">
          <el-button
            type="primary"
            class="generate-btn"
            :loading="isGenerating"
            @click="startGeneration"
          >
            {{ isGenerating ? "生成中..." : "生成数字人形象" }}
          </el-button>
        </div>
      </div>

      <!-- 右侧生成结果展示区域 -->
      <div class="result-section">
        <div class="section-title">
          <div class="title-with-action">
            <h2>生成结果</h2>
            <el-button
              v-if="hasResults"
              type="primary"
              class="regenerate-btn"
              @click="regenerate"
            >
              <el-icon><Refresh /></el-icon> 换一个吧
            </el-button>
          </div>
          <p class="description">基于您的照片生成的数字人营销图片</p>
        </div>

        <div v-if="hasResults" class="result-grid">
          <div v-for="(item, index) in resultItems" :key="index" class="result-item">
            <img :src="item.image" :alt="item.alt" class="result-image" />
            <div class="result-item-footer">
              <div class="result-style">{{ item.style }}</div>
              <div class="result-actions">
                <el-button
                  size="small"
                  type="primary"
                  plain
                  @click="downloadImage(item.image, item.alt)"
                >
                  <el-icon><Download /></el-icon>
                  <span>下载</span>
                </el-button>
              </div>
            </div>
          </div>
        </div>

        <div v-else class="empty-result">
          <el-empty description="暂无生成结果" />
          <p class="empty-tip">请上传图片并点击"生成数字人形象"按钮</p>
        </div>
      </div>
    </div>

    <!-- 添加生成成功动画 -->
    <div v-if="showSuccessAnimation" class="success-animation-container">
      <div class="success-animation">
        <div class="dynamic-island">
          <div class="island-background">
            <div class="checkmark-wrapper">
              <svg
                class="checkmark"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 52 52"
              >
                <circle class="checkmark-circle" cx="26" cy="26" r="25" fill="none" />
                <path
                  class="checkmark-path"
                  fill="none"
                  d="M14.1 27.2l7.1 7.2 16.7-16.8"
                />
              </svg>
            </div>
            <p class="success-message">生成成功</p>
          </div>
        </div>
      </div>
    </div>

    <!-- 添加一个全局居中的进度显示区域 -->
    <div v-if="isGenerating" class="global-progress-container">
      <div class="global-progress-card">
        <div class="progress-header">
          <div class="progress-icon">
            <el-icon :size="36"><Loading /></el-icon>
          </div>
          <h3>正在生成数字人形象</h3>
        </div>

        <div class="progress-steps">
          <div
            v-for="(step, index) in progressSteps"
            :key="index"
            class="progress-step-item"
            :class="{ active: step.progress <= generationProgress }"
          >
            <div class="step-dot" />
            <div class="step-text">{{ step.text }}</div>
          </div>
        </div>

        <el-progress
          :percentage="generationProgress"
          :status="generationProgress === 100 ? 'success' : ''"
          :stroke-width="20"
          :color="progressBarColors"
        />

        <p class="progress-text">
          <span class="progress-percentage">{{ generationProgress }}%</span>
          {{ progressText }}
        </p>
      </div>
    </div>

    <!-- 添加人脸选择前的加载动画 -->
    <div v-if="isLoadingFaces" class="global-progress-container">
      <div class="global-progress-card">
        <div class="progress-header">
          <div class="progress-icon">
            <el-icon :size="36"><Loading /></el-icon>
          </div>
          <h3>正在加载人脸模型</h3>
        </div>

        <div class="progress-steps">
          <div
            v-for="(step, index) in loadingSteps"
            :key="index"
            class="progress-step-item"
            :class="{ active: step.progress <= loadingProgress }"
          >
            <div class="step-dot" />
            <div class="step-text">{{ step.text }}</div>
          </div>
        </div>

        <el-progress
          :percentage="loadingProgress"
          :status="loadingProgress === 100 ? 'success' : ''"
          :stroke-width="20"
          :color="progressBarColors"
        />

        <p class="progress-text">
          <span class="progress-percentage">{{ loadingProgress }}%</span>
          {{ loadingText }}
        </p>
      </div>
    </div>

    <!-- 添加人脸选择对话框 -->
    <el-dialog
      v-model="showFaceSelectDialog"
      title="请选择人脸生成数字人形象"
      width="60%"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :show-close="false"
    >
      <div class="face-select-container">
        <div class="face-grid">
          <div
            v-for="(face, index) in availableFaces"
            :key="index"
            class="face-item"
            :class="{ selected: selectedFaceIndex === index }"
            @click="selectFace(index)"
          >
            <img :src="face.image" :alt="face.name" class="face-image" />
            <div class="face-name">{{ face.name }}</div>
          </div>
        </div>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="cancelFaceSelect">取消</el-button>
          <el-button
            type="primary"
            :disabled="selectedFaceIndex === -1"
            @click="confirmFaceSelect"
          >
            确认选择
          </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, computed } from "vue";
import { Upload, Download, Picture, Refresh, Loading } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";

// 常量配置
const CONSTANTS = {
  MAX_FILE_SIZE: 5, // 最大文件大小(MB)
  SUPPORTED_FORMATS: ["image/jpeg", "image/png"],
  PROGRESS_INTERVAL: 200, // 进度条更新间隔(ms)
  ANIMATION_DELAY: 500, // 动画延迟时间(ms)
};

// 图片预览相关状态
const previewImage = ref("");
const imageDescription = ref("");
const hasResults = ref(false);
const currentImageName = ref("");

// 导入测试图片资源
import result1 from "./images/古风正面(1).png";
import result2 from "./images/古风正面 (2).png";
import result3 from "./images/古风正面 (3).png";
import result4 from "./images/古风正面 (4).png";

import resultJia1 from "./images/对比发饰1.jpeg";
import resultJia2 from "./images/对比发饰2.png";
import resultJia3 from "./images/对比发饰3.jpg";
import resultJia4 from "./images/对比发饰4.png";

import face1 from "./images/face/Snipaste_2025-05-03_12-54-45.png";
import face2 from "./images/face/Snipaste_2025-05-03_12-56-01.png";

// 测试结果数据集1
const xuResultItems = reactive([
  {
    image: result1,
    alt: "生成结果1",
    style: "古风写真",
  },
  {
    image: result2,
    alt: "生成结果2",
    style: "传统服饰",
  },
  {
    image: result3,
    alt: "生成结果3",
    style: "古典意境",
  },
  {
    image: result4,
    alt: "生成结果4",
    style: "人物特写",
  },
]);

// 测试结果数据集2
const jiaResultItems = reactive([
  {
    image: resultJia1,
    alt: "生成结果1",
    style: "发饰风格1",
  },
  {
    image: resultJia2,
    alt: "生成结果2",
    style: "发饰风格2",
  },
  {
    image: resultJia3,
    alt: "生成结果3",
    style: "发饰风格3",
  },
  {
    image: resultJia4,
    alt: "生成结果4",
    style: "发饰风格4",
  },
]);

// 根据当前图片名称计算显示的结果集
const resultItems = computed(() => {
  if (currentImageName.value.includes("测试1")) {
    return jiaResultItems;
  } else if (currentImageName.value.includes("测试2")) {
    return jiaResultItems;
  }
  return jiaResultItems;
});

// 生成进度相关状态
const isGenerating = ref(false);
const generationProgress = ref(0);
const progressSteps = reactive([
  { progress: 10, text: "处理上传图片..." },
  { progress: 30, text: "分析人物特征..." },
  { progress: 50, text: "生成3D模型..." },
  { progress: 70, text: "应用风格转换..." },
  { progress: 90, text: "渲染最终效果..." },
  { progress: 100, text: "生成完成!" },
]);

// 计算当前进度文本
const progressText = computed(() => {
  const step = progressSteps.find((step) => step.progress >= generationProgress.value);
  return step ? step.text : "准备生成...";
});

// 进度条颜色配置
const progressBarColors = [
  { color: "#64b5f6", percentage: 0 },
  { color: "#42a5f5", percentage: 50 },
  { color: "#2196f3", percentage: 100 },
];

// 动画控制状态
const showSuccessAnimation = ref(false);

// 人脸选择相关状态
const showFaceSelectDialog = ref(false);
const selectedFaceIndex = ref(-1);
const availableFaces = ref([
  {
    image: face1,
    name: "古风写真",
  },
  {
    image: face2,
    name: "传统服饰",
  },
]);

// 人脸模型加载相关状态
const isLoadingFaces = ref(false);
const loadingProgress = ref(0);
const loadingSteps = reactive([
  { progress: 20, text: "初始化模型..." },
  { progress: 40, text: "加载人脸数据..." },
  { progress: 60, text: "处理特征点..." },
  { progress: 80, text: "优化显示效果..." },
  { progress: 100, text: "加载完成!" },
]);

// 计算加载进度文本
const loadingText = computed(() => {
  const step = loadingSteps.find((step) => step.progress >= loadingProgress.value);
  return step ? step.text : "准备加载...";
});

/**
 * 处理图片上传
 * @param {File} file - 上传的文件对象
 */
const handleImageChange = (file) => {
  // 验证文件格式和大小
  if (!CONSTANTS.SUPPORTED_FORMATS.includes(file.raw.type)) {
    ElMessage.error("请上传JPG或PNG格式的图片");
    return;
  }

  if (file.raw.size > CONSTANTS.MAX_FILE_SIZE * 1024 * 1024) {
    ElMessage.error(`图片大小不能超过${CONSTANTS.MAX_FILE_SIZE}MB`);
    return;
  }

  // 清空之前的状态
  if (previewImage.value) {
    hasResults.value = false;
    imageDescription.value = "";
  }

  // 读取并预览图片
  const reader = new FileReader();
  reader.onload = (e) => {
    previewImage.value = e.target.result;
  };
  reader.readAsDataURL(file.raw);

  // 保存文件名
  currentImageName.value = file.name || "";
};

/**
 * 选择人脸
 * @param {number} index - 选中的人脸索引
 */
const selectFace = (index) => {
  selectedFaceIndex.value = index;
};

/**
 * 取消人脸选择
 */
const cancelFaceSelect = () => {
  showFaceSelectDialog.value = false;
  selectedFaceIndex.value = -1;
};

/**
 * 确认人脸选择并开始生成
 */
const confirmFaceSelect = () => {
  if (selectedFaceIndex.value === -1) {
    ElMessage.warning("请选择一个人脸");
    return;
  }
  showFaceSelectDialog.value = false;
  startDigitalManGeneration();
};

/**
 * 开始生成流程
 */
const startGeneration = () => {
  if (isGenerating.value) return;

  if (!previewImage.value) {
    ElMessage.warning("请先上传照片");
    return;
  }

  loadFaces();
};

/**
 * 加载人脸模型
 */
const loadFaces = () => {
  isLoadingFaces.value = true;
  loadingProgress.value = 0;

  const interval = setInterval(() => {
    if (loadingProgress.value < 100) {
      loadingProgress.value += 5;
    } else {
      clearInterval(interval);
      setTimeout(() => {
        isLoadingFaces.value = false;
        showFaceSelectDialog.value = true;
      }, CONSTANTS.ANIMATION_DELAY);
    }
  }, CONSTANTS.PROGRESS_INTERVAL);
};

/**
 * 开始数字人生成过程
 */
const startDigitalManGeneration = () => {
  isGenerating.value = true;
  generationProgress.value = 0;
  hasResults.value = false;
  showSuccessAnimation.value = false;

  const interval = setInterval(() => {
    if (generationProgress.value < 100) {
      generationProgress.value += 5;
    } else {
      clearInterval(interval);
      setTimeout(() => {
        isGenerating.value = false;
        showSuccessAnimation.value = true;

        setTimeout(() => {
          showSuccessAnimation.value = false;
          hasResults.value = true;
        }, 2000);
      }, CONSTANTS.ANIMATION_DELAY);
    }
  }, CONSTANTS.PROGRESS_INTERVAL);
};

/**
 * 重新生成
 */
const regenerate = () => {
  startGeneration();
};

/**
 * 下载生成的图片
 * @param {string} imageUrl - 图片URL
 * @param {string} imageName - 图片名称
 */
const downloadImage = (imageUrl, imageName) => {
  try {
    const link = document.createElement("a");
    link.href = imageUrl;
    const fileName = `${imageName || "数字人形象"}_${new Date().getTime()}.png`;
    link.download = fileName;

    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);

    ElMessage.success("图片下载成功");
  } catch (error) {
    console.error("下载图片失败:", error);
    ElMessage.error("图片下载失败，请重试");
  }
};
</script>

<style scoped>
.digital-man-container {
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 80vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    Helvetica, Arial, sans-serif;
  padding-top: 0;
  max-width: unset;
}

.page-title {
  font-size: 28px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 30px;
  text-align: center;
}

.content-wrapper {
  display: flex;
  gap: 30px;
  background-color: #f5f5f7;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.upload-section,
.result-section {
  flex: 1;
  background-color: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.section-title {
  margin-bottom: 24px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 16px;
}

.section-title h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 8px;
}

.description {
  font-size: 14px;
  color: #86868b;
}

.upload-area {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.image-preview {
  width: 100%;
  height: 250px;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e6e6e6;
  background-color: #f5f5f7;
  display: flex;
  justify-content: center;
  align-items: center;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.upload-actions {
  text-align: center;
  margin-bottom: 16px;
}

.upload-btn {
  margin-bottom: 8px;
  font-weight: 500;
}

.upload-tip {
  font-size: 12px;
  color: #86868b;
}

/* 描述区域样式 */
.description-area {
  margin-bottom: 20px;
  width: 100%;
}

.textarea-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.required-mark {
  color: #f56c6c;
  margin-right: 4px;
}

.description-area h3 {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

.description-area :deep(.el-textarea__inner) {
  background-color: #f9f9f9;
  border-color: #e6e6e6;
  border-radius: 8px;
}

/* 进度区域样式 */
.progress-area {
  margin-bottom: 20px;
  padding: 16px;
  background-color: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #eee;
}

.progress-area h3 {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 12px 0;
}

.progress-text {
  margin-top: 10px;
  text-align: center;
  color: #606266;
  font-size: 14px;
}

.generation-actions {
  text-align: center;
}

.generate-btn {
  width: 100%;
  height: 44px;
  font-weight: 500;
  font-size: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.result-item {
  border-radius: 8px;
  background-color: #f5f5f7;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.result-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.result-image {
  width: 100%;
  height: 200px;
  object-fit: contain;
  border-radius: 8px 8px 0 0;
  background-color: #f5f5f7;
}

.result-item-footer {
  padding: 12px;
  background-color: white;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-style {
  font-size: 14px;
  color: #333;
  text-align: center;
  font-weight: 500;
}

.result-actions {
  text-align: center;
}

/* 媒体查询，确保在较小屏幕上也有良好的显示效果 */
@media (max-width: 1024px) {
  .content-wrapper {
    flex-direction: column;
  }

  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .result-grid {
    grid-template-columns: 1fr;
  }

  .image-preview {
    height: 200px;
  }
}

/* 空结果样式 */
.empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background-color: #f9f9f9;
  border-radius: 8px;
  padding: 20px;
}

.empty-tip {
  margin-top: 12px;
  color: #909399;
  font-size: 14px;
}

/* 上传区域样式 */
.upload-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #909399;
}

.upload-placeholder .el-icon {
  margin-bottom: 10px;
}

.upload-placeholder p {
  margin: 0;
  font-size: 14px;
}

.upload-component {
  width: 100%;
  text-align: center;
}

/* 全局进度条样式 */
.global-progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.global-progress-card {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  border-radius: 12px;
  padding: 30px;
  width: 550px;
  max-width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2), 0 0 20px rgba(33, 150, 243, 0.15);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  animation: slideUp 0.4s ease-out;
  overflow: hidden;
  position: relative;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.global-progress-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
  z-index: 0;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
  position: relative;
  z-index: 1;
}

.progress-icon {
  margin-right: 15px;
  color: #2196f3;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.global-progress-card h3 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: #0d47a1;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
  position: relative;
}

.global-progress-card .progress-text {
  margin-top: 20px;
  font-size: 16px;
  color: #1565c0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.progress-percentage {
  font-size: 24px;
  font-weight: 700;
  color: #1976d2;
  margin-bottom: 5px;
}

.global-progress-card :deep(.el-progress-bar__inner) {
  transition: all 0.5s ease-out;
}

.global-progress-card :deep(.el-progress-bar__outer) {
  background-color: rgba(33, 150, 243, 0.1);
  border-radius: 10px;
}

.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 25px;
  position: relative;
  z-index: 1;
}

.progress-step-item {
  display: flex;
  align-items: center;
  text-align: left;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.progress-step-item.active {
  opacity: 1;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #64b5f6;
  margin-right: 12px;
  position: relative;
}

.progress-step-item.active .step-dot {
  background-color: #2196f3;
  box-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
}

.step-dot::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #42a5f5;
  left: -7px;
  top: -7px;
  opacity: 0;
}

.progress-step-item.active .step-dot::before {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.2);
    opacity: 0;
  }
  100% {
    transform: scale(0.8);
    opacity: 0;
  }
}

.step-text {
  font-size: 14px;
  color: #0d47a1;
}

.progress-step-item.active .step-text {
  color: #0d47a1;
  font-weight: 600;
}

/* 标题和操作按钮样式 */
.title-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.regenerate-btn {
  font-size: 12px;
}

/* 成功动画样式 - 灵动岛风格 */
.success-animation-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  animation: backdropFadeIn 0.3s cubic-bezier(0.33, 1, 0.68, 1);
  backdrop-filter: blur(5px);
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(5px);
  }
}

.success-animation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dynamic-island {
  padding: 10px;
  perspective: 1000px;
}

.island-background {
  width: 250px;
  height: 250px;
  border-radius: 50px;
  background-color: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  animation: scaleIsland 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center center;
}

@keyframes scaleIsland {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  40% {
    transform: scale(1.1);
  }
  60% {
    transform: scale(0.96);
  }
  80% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.checkmark-wrapper {
  width: 80px;
  height: 80px;
  background-color: transparent;
  position: relative;
  margin-bottom: 16px;
  animation: fadeInWrapper 0.3s cubic-bezier(0.33, 1, 0.68, 1) forwards;
  opacity: 0;
  animation-delay: 0.2s;
}

@keyframes fadeInWrapper {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* SVG动画样式 */
.checkmark {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  stroke-width: 3;
  stroke: #5ce679;
  stroke-miterlimit: 10;
  box-shadow: 0 0 15px #5ce679;
}

.checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: #5ce679;
  fill: none;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
  animation-delay: 0.4s;
}

.checkmark-path {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke-width: 3;
  stroke: #5ce679;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
  animation-delay: 0.8s;
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}

.success-message {
  color: white;
  font-size: 18px;
  font-weight: 500;
  margin: 0;
  opacity: 0;
  animation: fadeInMessage 0.4s cubic-bezier(0.33, 1, 0.68, 1) forwards;
  animation-delay: 1.2s;
}

@keyframes fadeInMessage {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 人脸选择对话框样式 */
.face-select-container {
  padding: 20px;
}

.face-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.face-item {
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.face-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.face-item.selected {
  border-color: #409eff;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

.face-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 6px;
}

.face-name {
  text-align: center;
  padding: 8px;
  font-size: 14px;
  color: #606266;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
</style>
